import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
Vue.use(Antd)
Vue.config.productionTip = false;
// 路由的全局钩子函数  路由跳转前钩子函数
router.beforeEach((to, from, next) => {
  // to  即将进入的组件信息  to.path. to.name to.meta.keepAlive to.params
  // from  即将离家的组件信息 from.path from.name from.meta from.params
  // next()  继续操作  next("/login") 跳转组件
  console.log(from)
  if (to.name == "cart") {
    if (!localStorage.token) {
      next("/home")
    }
  }
  next();
})

// 路由跳转后的全局钩子函数
router.afterEach((to, from) => {
  console.log(from)
  console.log(to)
  // to  即将进入的组件信息  to.path. to.name to.meta.keepAlive to.params
  // from  即将离家的组件信息 from.path from.name from.meta from.params
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
